package com.gt.andr.multbl;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 
 * @author Ganesh
 * 
 */
public class MultiplicationListener implements TextWatcher {

	TextView textView;
	EditText valueField;

	public MultiplicationListener(TextView textView, EditText valueField) {
		this.textView = textView;
		this.valueField = valueField;
	}

	@Override
	public void afterTextChanged(Editable s) {
		String number = valueField.getText().toString().trim();
		if (!number.isEmpty() && !number.equals("0")) {
			textView.setText(MultiplicationTable.getStringTable(Integer.parseInt(number)));
		}

	}

	@Override
	public void beforeTextChanged(CharSequence s, int start, int count, int after) {

	}

	@Override
	public void onTextChanged(CharSequence s, int start, int before, int count) {

	}

}
